package com.yunsom.testdemo.mysql;

/**
 * @author Xbao
 * @description
 * @date 2022/9/22 17:12
 */
public class SqlTest {

  public static void main(String[] args) {
    /*
      mysql 数据表批量造数据:
      DROP PROCEDURE IF EXISTS proc_initData;--如果存在此存储过程则删掉
      DELIMITER $
      CREATE PROCEDURE proc_initData()
      BEGIN
          DECLARE i INT DEFAULT 1;
          WHILE i<=10000000 DO

              #此处替换成自己想要执行的insert语句l
              INSERT INTO `test2_epidemic_cq`.`nucleic_acid_test_detail`
              (`id`, `test_result_id`, `hs_id`, `card_no`, `phone`, `name`, `address`, `collect_pos`, `result`, `barcode`, `org_name`, `sample_type`, `collect_date`, `receive_date`, `upload_date`, `created_at`, `updated_at`, `is_deleted`) VALUES (i+1, i+2, substring(md5(rand()), 1, 20),
              substring(md5(rand()), 1, 20), '1231', '1231', '1231', '1231', 1, '123', '12132', '1123', DATE_ADD('2022-01-01 00:00:00',  INTERVAL  FLOOR(1 + (RAND() * 10800))   HOUR ) , '2022-09-22 14:28:13', '2022-09-22 14:28:13', '2022-09-22 14:28:13', '2022-09-22 14:28:13', 2);

              SET i = i+1;
          END WHILE;
      END $
      CALL proc_initData();
     */

    // mysql生成随机字符串 substring(md5(rand()), 1, length)

    // mysql生成指定时间范围内的日期数据 DATE_ADD('2022-01-01 00:00:00',  INTERVAL  FLOOR(1 + (RAND() * 10800))   HOUR )
  }
}
